package com.juyu.miliao.api.controller;

import com.juyu.miliao.api.domain.vo.AreaVo;
import com.juyu.miliao.api.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

/**
 * 地区
 *
 * @author xuanqicheng
 * @create 2019-08-13:08
 */
@RestController
@RequestMapping("/area")
public class AreaController {
    @Autowired
    private AreaService areaService;

    @GetMapping("/province")
    public List<String> getProvinceList(){
        List<String> provinceList = areaService.selectProvinceList();
        return provinceList;
    }

    @GetMapping("/")
    public List<AreaVo> getAreaList() throws IOException {
        return areaService.selectAreaList();
    }

    /**
     * 根据省份查询市
     */
    @PostMapping("/city")
    public List<String> getCityList(String province){
        List<String> cityList = areaService.selectCityByProvince(province);
        return cityList;
    }
}
